export const fillZero = (str: number) => {
  let realNum: any
  if (str < 10) {
    realNum = '0' + str
  } else {
    realNum = str
  }
  return realNum
}
// 时间戳转换
export const timeChange = (date) => {
  const timeDate = new Date(date)
  const time = `${timeDate.getFullYear()}-${fillZero(timeDate.getMonth() + 1)}-${fillZero(
    timeDate.getDate()
  )}
    ${fillZero(timeDate.getHours())}:${fillZero(timeDate.getMinutes())}:${fillZero(
    timeDate.getSeconds()
  )}秒`
  return time
}
//国际时间转换
export const formatDate = (d: string) => {
  const date = new Date(d)
  const YY = date.getFullYear() + '-'
  const MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
  const DD = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
  const hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'
  const mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':'
  const ss = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
  return YY + MM + DD + ' ' + hh + mm + ss
}
